<?php
if (isset($_POST["login"]) && isset($_POST["motdepasse"]))	{
	require("../includes/configDB.inc.php");
	require("../includes/fonctions.php");
	
	lnmConnectDB();	
	$login=sqlString($_POST["login"]);
	$password=sha1($_POST["motdepasse"]);
		
	$query = "SELECT * FROM lnmadmin WHERE login='".$login."' AND password='".$password."'";
	$result = lnmQuery($query);

	if (mysql_num_rows($result)>0) {
		session_start ();
   	$_SESSION['adminLogin']=mysql_result($result,0,"login");
		$_SESSION['adminSuper']=mysql_result($result,0,"superAdmin");
		$_SESSION['adminId']=mysql_result($result,0,"id");
	
		include "includes/adminFct.php";
		logs($_SESSION['adminLogin'],"Connexion","IP : ".$_SERVER['REMOTE_ADDR'],"1");
		majConnect($_SESSION['adminLogin']);
		header("location: ./");
		exit();
	}	else {
		header ("location:verification.php?login=".$_POST['login']."&erreur=1" );
		exit();
	}
}
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="fr" lang="fr">
<head>
   <meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-15" />
   <title>Administration LNM</title>
   <link rel="stylesheet" href="includes/admin.css" media="screen" />
</head>
<body>

	<form method="post" action="verification.php" id="blogAdmin">
		<table id="logAdmin">
			<tr>
				<th colspan="2">
					<h1>Administration du Nouveau Monde</h1>
				</th>
			</tr>
			<?php
				if(isset($_GET["erreur"]) && !empty($_GET["erreur"])){
					echo '<tr>
									<td colspan="2">
										<div class="erreur">Erreur d\'identification - Login et/ou mot de passe incorrect</div>
									</td>
								</tr>';
				}
			?>
			<tr>
				<td>Login</td>
				<td><input type="text" name="login" value="<?php echo $_GET["login"] ?>" /></td>
			</tr>
			<tr>
				<td>Mot de passe</td>
				<td><input type="password" name="motdepasse" /</td>
			</tr>
			<tr>
				<td colspan="2">
					<input class="bouton" type="submit" value="Connexion" />
				</td>
			</tr>
		</table>
					
	</form>
</body>
</html>		
